'Imports MagicAjax
Imports Microsoft.VisualBasic

Namespace Utility

    Public Class Js
        Public Shared Sub alert(ByVal Page As Object, ByVal msg As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & msg & "');</script>")
        End Sub

        Public Shared Sub alert_ajax(ByVal msg As String)
            ' AjaxCallHelper.Write("alert('" & msg & "');")
            'ajax.RegisterClientScriptBlock(page, page.GetType, "Onload", "<script>alert('" & msg & "');</script>", False)
        End Sub

        Public Shared Sub alert_locationAjax(ByVal msg As String, ByVal pLocation As String)
            ' AjaxCallHelper.Write("alert('" & msg & "');window.location='" & pLocation & "';")
            'ajax.RegisterClientScriptBlock(page, page.GetType, "Onload", "<script>alert('" & msg & "');</script>", False)
        End Sub

        Public Shared Sub alert_location(ByVal Page As Object, ByVal msg As String, ByVal pLocation As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & msg & "');window.location='" & pLocation & "';</script>")
        End Sub

        Public Shared Sub alert_closeAjax(ByVal msg As String)
            ' AjaxCallHelper.Write("alert('" & msg & "');window.close();")
        End Sub

        Public Shared Sub alert_close(ByVal Page As Object, ByVal msg As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & msg & "');window.close();</script>")
        End Sub

        Public Shared Sub close_page(ByVal Page As Object)
            Page.RegisterStartupScript("Onload", "<script>window.close();</script>")
        End Sub

        Public Shared Sub window_open(ByVal page As Object, ByVal strPath As String, Optional ByVal width As Integer = 500, Optional ByVal height As Integer = 750)
            page.ClientScript.RegisterStartupScript(page.GetType, "onload", "window.open('" & strPath & "','Viewwin','top=100,left=300,toolbar=0, location=0, directories=0, status=1, menubar=0, scrollbars=1, resizable=1, height=" & height & ", width=" & width & "');", True)
        End Sub

        Public Shared Sub windowRefresh_Ajax(ByVal strMsg As String, ByVal PageRefresh As String)
            ' AjaxCallHelper.Write("alert('" & strMsg & "');self.opener.location='" & PageRefresh & "';window.close();")
            'ScriptManager.RegisterClientScriptBlock(Page, Page.GetType, "Onload", "<script>alert('" & strMsg & "');self.opener.location='" & PageRefresh & "';window.close();</script>", False)
        End Sub

        Public Shared Sub windowRefresh(ByVal Page As Object, ByVal strMsg As String, ByVal PageRefresh As String)
            Page.RegisterStartupScript("Onload", "<script>alert('" & strMsg & "');self.opener.location='" & PageRefresh & "';window.close();</script>")
            'ScriptManager.RegisterClientScriptBlock(Page, Page.GetType, "Onload", "<script>alert('" & strMsg & "');self.opener.location='" & PageRefresh & "';window.close();</script>", False)

        End Sub

        Public Shared Sub windowLocation(ByVal p As Page, ByVal PageLocation As String)
            p.ClientScript.RegisterClientScriptBlock(GetType(String), "WindowLocation", "window.location='" & PageLocation & "';", True)
            'ScriptManager.RegisterClientScriptBlock(p, GetType(String), "WindowLocation", "window.location='" & PageLocation & "';", True)
        End Sub

    End Class

End Namespace
